
<script >
	function addElement() {

	  var ni = document.getElementById('myDiv');

	  var numi = document.getElementById('theValue');

	  var num = (document.getElementById('theValue').value -1)+ 2;

	  numi.value = num;

	  var newdiv = document.createElement('div');

	  var divIdName = 'my'+num+'Div';

	  newdiv.setAttribute('id',divIdName);
	  newdiv.setAttribute('style','float:left; width:100%');

	  newdiv.innerHTML = '<p><input type="hidden" id="userfile'+num+'" name="sanpham_hinhanh'+num+'" value=""/><img src="" width="50" id="imgdef'+num+'" name="imgdef'+num+'" height="40" style="float:left; border:#CCC 1px solid" /><input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open(\'Upfile.php?Dir=sanpham&amp;form=userfile'+num+'&img=imgdef'+num+'\',\'_upLoad\' ,\'height=220,width=450,resizable=no,scrollbars=yes\')") />&nbsp; <a href="javascript:;" onclick="removeElement(\''+divIdName+'\');">Xóa</a></p>';

	  ni.appendChild(newdiv);

	}
	function removeElement(divNum) {

	  var vl = document.getElementById('theValue');
	  vl.value= vl.value-1;
	  var d = document.getElementById('myDiv');

	  var olddiv = document.getElementById(divNum);

	  d.removeChild(olddiv);

	}
</script>
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">

	// O2k7 skin
tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		width : "700",
		height : "300",
		skin : "o2k7",
		plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,autosave,visualblocks",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,sub,sup,link,unlink,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		theme_advanced_path : false, 
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",


	});
				
/* Default skin */



</script>

<script language="javascript">
function validate_form(thisform)
{
with (thisform)
{
	
	
	if (validate_required(task_name,"Bạn chưa nhập tên công việc !")==false)
 	{task_name.focus();return false;}
	
	if (validate_required(contract_start,"Bạn chưa chọn ngày bắt đầu !")==false)
 	{contract_start.focus();return false;}
	if (validate_required(contract_end,"Bạn chưa chọn ngày kết thúc !")==false)
 	{contract_end.focus();return false;}
	if (validate_required(nguoitiepnhan,"Bạn chưa chọn người tiếp nhận !")==false)
 	{nguoitiepnhan.focus();return false;}
	if (validate_required(mucdo,"Bạn chưa chọn mức độ ưu tiên !")==false)
 	{mucdo.focus();return false;}
	
	

}
}
</script>

 <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="text-top">.:. Thêm công việc phát sinh</td>
        </tr>
      </tbody></table>
      <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="t-l"></td>
          <td class="t-c"></td>
          <td class="t-r"></td>
        </tr>
        <tr class="light">
          <td class="c-l"></td>
          <td class="c-c" valign="top">
          	<form action="index.php?tn=xuly_phatsinh" onsubmit="return validate_form(this);" name="frmAddMessage" id="theform" method="post" enctype="multipart/form-data">
              <table border="0" cellpadding="0" cellspacing="0" height="10" width="100%">
                <tbody><tr class="light">
                  <td><img src="index2.php_files/spaces.gif" height="1" width="1"></td>
                </tr>
              </tbody></table>
              <table class="font_11" border="0" cellpadding="5" cellspacing="0" width="100%">
                <tbody>
          <tr class="light" id="tieudeyeucau" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td id="tieudeyeucau1" class="tdbg_2"><span><strong>Thông tin công việc</strong><span class="color_khancap"></span></span></td>
                  <td id="tieudeyeucau2" class="tdbg_2">:</td>
                  <td id="tieudeyeucau3" class="tdbg_2">
                  	<table>
                    	<tr>
                        	<td style="color:#060; font-weight:bold;">Tên công việc</td>
                            <td><input class="box_input" name="task_name" type="text" style="width:500px;"> </td>
                  		</tr>
                        <tr>
                        	<td style="color:#060; font-weight:bold;" width="10%"> Ngày bắt đầu: </td>
                            <td>  <input class="box_input" name="contract_start" id="contract_start" type="text" width="15" />
                     <script type="text/javascript">
							$(function()
							{
								var arrayDayName=["CN","Hai","Ba","Tư","Năm","Sáu","Bảy"];
								var arrayMonthName=["Tháng 1","Tháng 2","Tháng 3","Tháng 4","Tháng 5","Tháng 6","Tháng 7","Tháng 8","Tháng 9","Tháng 10","Tháng 11","Tháng 12"];
								
								$('#contract_start').datepicker({
									yearRange: 'c-12:c+8',
									changeMonth: true,
									changeYear: true,
									dateFormat: 'dd-mm-yy',
									showAnim: 'slideDown',
									monthNamesShort:arrayMonthName,
									dayNamesMin:arrayDayName
								});										
							});	
						</script>
                        	</td>
                            <td style="color:#060; font-weight:bold;" width="10%">Ngày kết thúc:  </td>
                            <td width="20%">  <input class="box_input" name="contract_end" id="contract_end" type="text" width="15" />
                     <script type="text/javascript">
							$(function()
							{
								var arrayDayName=["CN","Hai","Ba","Tư","Năm","Sáu","Bảy"];
								var arrayMonthName=["Tháng 1","Tháng 2","Tháng 3","Tháng 4","Tháng 5","Tháng 6","Tháng 7","Tháng 8","Tháng 9","Tháng 10","Tháng 11","Tháng 12"];
								
								$('#contract_end').datepicker({
									yearRange: 'c-12:c+8',
									changeMonth: true,
									changeYear: true,
									dateFormat: 'dd-mm-yy',
									showAnim: 'slideDown',
									monthNamesShort:arrayMonthName,
									dayNamesMin:arrayDayName
								});										
							});	
						</script> 
                        	
                        </tr>
                        <tr> 
                        	<td style="color:#060; font-weight:bold;" width="20%"> Đăng ký ngày thực hiện</td>
                            <td width="60%">
                             <input type="checkbox" name="date1" value="1"/>01
                            <input type="checkbox" name="date2" value="2"/>02
                            <input type="checkbox" name="date3" value="3"/>03
                            <input type="checkbox" name="date4" value="4"/>04
                            <input type="checkbox" name="date5" value="5"/>05
                            <input type="checkbox" name="date6" value="6"/>06
                            <input type="checkbox" name="date7" value="7"/>07
                            <input type="checkbox" name="date8" value="8"/>08
                            <input type="checkbox" name="date9" value="9"/>09
                            <input type="checkbox" name="date10" value="10"/>10<br />
                            <input type="checkbox" name="date11" value="11"/>11
                            <input type="checkbox" name="date12" value="12"/>12
                            <input type="checkbox" name="date13" value="13"/>13
                            <input type="checkbox" name="date14" value="14"/>14
                            <input type="checkbox" name="date15" value="15"/>15
                            <input type="checkbox" name="date16" value="16"/>16
                            <input type="checkbox" name="date17" value="17"/>17
                            <input type="checkbox" name="date18" value="18"/>18
                            <input type="checkbox" name="date19" value="19"/>19
                            <input type="checkbox" name="date20" value="20"/>20<br />
                            <input type="checkbox" name="date21" value="21"/>21
                            <input type="checkbox" name="date22" value="22"/>22
                            <input type="checkbox" name="date23" value="23"/>23
                            <input type="checkbox" name="date24" value="24"/>24
                            <input type="checkbox" name="date25" value="25"/>25
                            <input type="checkbox" name="date26" value="26"/>26
                            <input type="checkbox" name="date27" value="27"/>27
                            <input type="checkbox" name="date28" value="28"/>28
                            <input type="checkbox" name="date29" value="29"/>29
                            <input type="checkbox" name="date30" value="30"/>30
                            <input type="checkbox" name="date31" value="31"/>31 
                            </td>
                            </td>
                            <td width="15%"> 
                 			Tháng
                    		<input type="text" name="month"  value="<?php echo date('m',time());?>" style="width:30px" readonly="readonly"/> 
                 			</td>
                  			<td width="10%"> 
                 			Năm
                   			<input type="text"  name="year" value="<?php echo date('Y',time());?>" style="width:30px"  readonly="readonly"/> 
                 			</td>
                        </tr>
                       </table>
                  </td> 
                </tr>
                 <tr class="light" id="tieudeyeucau" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td id="tieudeyeucau1" class="tdbg_2"><span><strong>Mức độ ưu tiên</strong><span class="color_khancap"></span></span></td>
                  <td id="tieudeyeucau2" class="tdbg_2">:</td>
                  <td id="tieudeyeucau3" class="tdbg_2">
                              <select name="mucdo" id="mucdo"> 
                                <option value="">--Vui lòng chọn--</option> 
                                <option value="1">Thấp</option> 
                                <option value="2">Trung bình</option> 
                                <option value="3">Cao</option> 
                              </select>                  		                  
                  </td>
                </tr>
 				
                 <tr class="light" id="tieudeyeucau" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td id="tieudeyeucau1" class="tdbg_2"><span><strong>Người duyệt</strong><span class="color_khancap"></span></span></td>
                  <td id="tieudeyeucau2" class="tdbg_2">:</td>
                  <td id="tieudeyeucau3" class="tdbg_2">
                             <?php 
							 	
							 	$sqlduyet=mysql_query("select * from tb_account_admin where level=2");
							 ?>
                             <select name="duyet">
                             	<option value="">--Chọn-- </option>
                               <?php while($rsduyet=mysql_fetch_array($sqlduyet)){?> 
                                <option value="<?php echo $rsduyet['account_id'];?>"><?php echo $rsduyet['account_name'];?> </option>
                                <?php }?>
                             </select>
                             (<span style="font-style:italic">Chọn người duyệt nếu cần duyệt công việc trước khi thực hiện </span>)  		                  
                  </td>
                </tr>
                <tr class="light" id="cauhoi" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)" bgcolor="">
                  <td class="tdbg_2" id="cauhoi1"><strong>Mô tả công việc</strong><span class="color_khancap">*</span></td>
                  <td class="tdbg_2" id="cauhoi2">:</td>
                  <td class="tdbg_2" id="cauhoi3">                     
                   	<div style="width:700px;">
					<textarea name="brief" id="txtnoidung" rows="15" cols="80" style="width: 80%"></textarea>  
                    	
                    </div>        
                </tr>
                <tr class="light" id="hinhanh" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td class="tdbg_2" id="hinhanh1">File đính kèm nếu có<br>
                    (*.gif, *.jpg, *.png, .doc, .pdf &lt; &nbsp;5000Kb)</td>
                  <td class="tdbg_2" id="hinhanh2">:</td>
                   <td id="myDiv" class="tdbg_2">
							<div style="float:left; width:100%; margin-top:5px;">
                            
<?php 
$soanh=1;
?>
								<input type="hidden" id="userfile1" name="sanpham_hinhanh1"  value="<?php  echo $arr_hinhanh[0]?>"/>
								<?php if($arr_hinhanh[0]==""){$sanpham_hinhanh="upload/hinhanh/photo.jpg";}else $sanpham_hinhanh = $arr_hinhanh[0];?>
								<img src="<?php  echo $sanpham_hinhanh?>" width="50" id="imgdef1" name="imgdef1" height="40" style="float:left; border:#CCC 1px solid" />
								
								<input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open('Upfile.php?Dir=sanpham&amp;form=userfile1&img=imgdef1','_upLoad' ,'height=220,width=450,resizable=no,scrollbars=yes')") />
								
								<input type="hidden" value="<?php echo $soanh;?>" name="hdnsoanh" id="theValue" />
								<a href="javascript:;" onclick="addElement();">Thêm file đính kèm</a>
							</div>
							<?php
								for($i=2; $i<=$soanh;$i++){
								$hinhanh = $arr_hinhanh[$i-1];
							?>
								<div id="my<?php echo $i;?>Div" style="float:left; width:100%; margin-top:5px;">
									<input type="hidden" id="userfile<?php echo $i;?>" name="sanpham_hinhanh<?php echo $i;?>"  value="<?php  echo $hinhanh?>"/>
									<img src="<?php echo $hinhanh?>" width="50" id="imgdef<?php echo $i;?>" name="imgdef<?php echo $i;?>" height="40" style="float:left; border:#CCC 1px solid" />
								  
								   <input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open('Upfile.php?Dir=sanpham&amp;form=userfile<?php echo $i;?>&img=imgdef<?php echo $i;?>','_upLoad' ,'height=220,width=450,resizable=no,scrollbars=yes')") />
								 
								   <a href="javascript:;" onclick="removeElement('my<?php echo $i;?>Div');">Delete</a>
								</div>
							<?php
								}
							?>
						   </td>
                </tr>
                <tr class="light" id="bonut" onmouseover="mouse_den(this)" onmouseout="mouse_di(this)">
                  <td class="tdbg_2" id="bonut1">&nbsp;</td>
                  <td class="tdbg_2" id="bonut2">&nbsp;</td>
                  <td class="tdbg_2" id="bonut3"><input class="buttonnew" name="submit" value="Gửi Yêu Cầu" onclick="SelectAll('NGUOIXULY')" type="submit">
                    &nbsp;
                    <input name="Submit2" class="buttonnew" value="&nbsp;Làm lại&nbsp;" type="reset"></td>
                </tr>
              </tbody></table>
              <table border="0" cellpadding="0" cellspacing="0" height="10" width="100%">
                <tbody><tr class="light">
                  <td><img src="index2.php_files/spaces.gif" border="0" height="1" width="1"></td>
                </tr>
              </tbody></table>
            </form></td>
          <td class="c-r"></td>
        </tr>
        <tr class="light">
          <td class="b-l"></td>
          <td class="b-c"></td>
          <td class="b-r"></td>
        </tr>
      </tbody></table>
      
